﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using Financeiro.Model;

namespace Financeiro
{
    /// <summary>
    /// Summary description for FinAdmWS
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class FinAdmWS : System.Web.Services.WebService
    {

        [WebMethod]
        public DataTable obterRelatorioDebito(DateTime inicio, DateTime fim)
        {
            DataTable relatorio = null;
            if (inicio.CompareTo(fim) < 0)
            {
                try
                {
                    relatorio = ContasModel.listContas(1, inicio, fim);
                }
                catch
                {
                    relatorio = null;
                }
            }
            return relatorio;

        }


        [WebMethod]
        public DataTable obterRelatorioCredito(DateTime inicio, DateTime fim)
        {
            DataTable relatorio = null;
            if (inicio.CompareTo(fim) < 0)
            {
                try
                {
                relatorio = ContasModel.listContas(0, inicio, fim);
                }
                catch
                {
                    relatorio = null;
                }
            }
            return relatorio;
        }

        [WebMethod]
        public DataTable obterServicosPorConta(int idConta)
        {

            DataTable relatorio = null;
            try
            {
                relatorio = ContasModel.listarServicos(idConta);
            }
            catch
            {
                relatorio = null;
            }

            return relatorio;
        }

    }
}
